package br.com.sistema.models;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

@Entity
@Table(name="endereco_tipo")
public class EnderecoTipo {

	@Id
	@Column(name="endetipoid")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int endetipoid;
	
	@Column(name="endetiponome", length=50, nullable=false)
	private String endetiponome;
	
	@Column(name="endetiposigla", length=3, nullable=false)
	private String endetiposigla;

	@Column(name="xdatai", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)  
	private Calendar xdatai;
	
	@Column(name="xdatau", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)  
	private Calendar xdatau;
	
	@Column(name="xusuario", nullable=false)
	private String xusuario;

	@Version
	@Column(name="xversao")
	private Integer xversao;
	
	public int getEndetipoid() {
		return endetipoid;
	}

	public void setEndetipoid(int endetipoid) {
		this.endetipoid = endetipoid;
	}

	public String getEndetiponome() {
		return endetiponome;
	}

	public void setEndetiponome(String endetiponome) {
		this.endetiponome = endetiponome;
	}

	public String getEndetiposigla() {
		return endetiposigla;
	}

	public void setEndetiposigla(String endetiposigla) {
		this.endetiposigla = endetiposigla;
	}

	public Calendar getXdatai() {
		return xdatai;
	}

	public void setXdatai(Calendar xdatai) {
		this.xdatai = xdatai;
	}

	public Calendar getXdatau() {
		return xdatau;
	}

	public void setXdatau(Calendar xdatau) {
		this.xdatau = xdatau;
	}

	public String getXusuario() {
		return xusuario;
	}

	public void setXusuario(String xusuario) {
		this.xusuario = xusuario;
	}
	
	@PrePersist
	public void prePersist(){
		xdatai = Calendar.getInstance();
		xdatau = Calendar.getInstance();
	}
	
	@PreUpdate
	public void preUpdate(){
		xdatau = Calendar.getInstance();
	}
}
